#include "versions.h"
#include "symbol.h"

#include <bitset>

#include <QDebug>

namespace qrcode{

Versions::Versions()
{
    versionsL.push_back(Version(1, 'L', 152, 19, 41, 25, 17, 10, 7, 1, 19, 0, 0));
    versionsM.push_back(Version(1, 'M', 128, 16, 34, 20, 14, 8, 10, 1, 16, 0, 0));
    versionsQ.push_back(Version(1, 'Q', 104, 13, 27, 16, 11, 7, 13, 1, 13, 0, 0));
    versionsH.push_back(Version(1, 'H', 72, 9, 17, 10, 7, 4, 17, 1, 9, 0, 0));

    versionsL.push_back(Version(2, 'L', 272, 34, 77, 47, 32, 20, 10, 1, 34, 0, 0));
    versionsM.push_back(Version(2, 'M', 224, 28, 63, 38, 26, 16, 16, 1, 28, 0, 0));
    versionsQ.push_back(Version(2, 'Q', 176, 22, 48, 29, 20, 12, 22, 1, 22, 0, 0));
    versionsH.push_back(Version(2, 'H', 128, 16, 34, 20, 14, 8, 28, 1, 16, 0, 0));

    versionsL.push_back(Version(3, 'L', 440, 55, 127, 77, 53, 32, 15, 1, 55, 0, 0));
    versionsM.push_back(Version(3, 'M', 352, 44, 101, 61, 42, 26, 26, 1, 44, 0, 0));
    versionsQ.push_back(Version(3, 'Q', 272, 34, 77, 47, 32, 20, 18, 2, 17, 0, 0));
    versionsH.push_back(Version(3, 'H', 208, 26, 58, 35, 24, 15, 22, 2, 13, 0, 0));

    versionsL.push_back(Version(4, 'L', 640, 80, 187, 114, 78, 48, 20, 1, 80, 0, 0));
    versionsM.push_back(Version(4, 'M', 512, 64, 149, 90, 62, 38, 18, 2, 32, 0, 0));
    versionsQ.push_back(Version(4, 'Q', 384, 48, 111, 67, 46, 28, 26, 2, 24, 0, 0));
    versionsH.push_back(Version(4, 'H', 288, 36, 82, 50, 34, 21, 16, 4, 9, 0, 0));

    versionsL.push_back(Version(5, 'L', 864, 108, 255, 154, 106, 65, 26, 1, 108, 0, 0));
    versionsM.push_back(Version(5, 'M', 688, 86, 202, 122, 84, 52, 24, 2, 43, 0, 0));
    versionsQ.push_back(Version(5, 'Q', 496, 62, 144, 87, 60, 37, 18, 2, 15, 2, 16));
    versionsH.push_back(Version(5, 'H', 368, 46, 106, 64, 44, 27, 22, 2, 11, 2, 12));

    versionsL.push_back(Version(6, 'L', 1088, 136, 322, 195, 134, 82, 18, 2, 68, 0, 0));
    versionsM.push_back(Version(6, 'M', 864,  108, 255, 154, 106, 65, 16, 4, 27, 0, 0));
    versionsQ.push_back(Version(6, 'Q', 608,  76,  178, 108, 74,  45, 24, 4, 19, 0, 0));
    versionsH.push_back(Version(6, 'H', 480,  60,  139, 84,  58,  36, 28, 4, 15, 0, 0));

    versionsL.push_back(Version(7, 'L', 1248, 156, 370, 224, 154, 95, 20, 2, 78, 0, 0));
    versionsM.push_back(Version(7, 'M', 992,  124, 293, 178, 122, 75, 18, 4, 31, 0, 0));
    versionsQ.push_back(Version(7, 'Q', 704,  88,  207, 125, 86,  53, 18, 2, 14, 4, 15));
    versionsH.push_back(Version(7, 'H', 528,  66,  154, 93,  64,  39, 26, 4, 13, 1, 14));

    versionsL.push_back(Version(8, 'L', 1552, 194, 461, 279, 192, 118, 24, 2, 97, 0, 0));
    versionsM.push_back(Version(8, 'M', 1232, 154, 365, 221, 152, 93, 22, 2, 38, 2, 39));
    versionsQ.push_back(Version(8, 'Q', 880,  110, 259, 157, 108, 66, 22, 4, 18, 2, 19));
    versionsH.push_back(Version(8, 'H', 688,  86,  202, 122, 84,  52, 26, 4, 14, 2, 15));

    versionsL.push_back(Version(9, 'L', 1856, 232, 552, 335, 230, 141, 30, 2, 116, 0, 0));
    versionsM.push_back(Version(9, 'M', 1456, 182, 432, 262, 180, 111, 22, 3, 36, 2, 37));
    versionsQ.push_back(Version(9, 'Q', 1056, 132, 312, 189, 130, 80, 20, 4, 16, 4, 17));
    versionsH.push_back(Version(9, 'H', 800,  100, 235, 143, 98, 60, 24, 4, 12, 4, 13));

    versionsL.push_back(Version(10, 'L', 2192, 274, 652, 395, 271, 167, 18, 2, 68, 2, 69));
    versionsM.push_back(Version(10, 'M', 1728, 216, 513, 311, 213, 131, 26, 4, 43, 1, 44));
    versionsQ.push_back(Version(10, 'Q', 1232, 154, 364, 221, 151, 93, 24, 6, 19, 2, 20));
    versionsH.push_back(Version(10, 'H', 976,  122, 288, 174, 119, 74, 28, 6, 15, 2, 16));

    versionsL.push_back(Version(11, 'L', 2592, 324, 772, 468, 321, 198, 20, 4, 81, 0, 0));
    versionsM.push_back(Version(11, 'M', 2032, 254, 604, 366, 251, 155, 30, 1, 50, 4, 51));
    versionsQ.push_back(Version(11, 'Q', 1440, 180, 427, 259, 177, 109, 28, 4, 22, 4, 23));
    versionsH.push_back(Version(11, 'H', 1120, 140, 331, 200, 137, 85, 24, 3, 12, 8, 13));

    versionsL.push_back(Version(12, 'L', 2960, 370, 883, 535, 367, 226, 24, 2, 92, 2, 93));
    versionsM.push_back(Version(12, 'M', 2320, 290, 691, 419, 287, 177, 22, 6, 36, 2, 37));
    versionsQ.push_back(Version(12, 'Q', 1648, 206, 489, 296, 203, 125, 26, 4, 20, 6, 21));
    versionsH.push_back(Version(12, 'H', 1264, 158, 374, 227, 155, 96, 28, 7, 14, 4, 15));

    versionsL.push_back(Version(13, 'L', 3424, 428, 1022, 619, 425, 262, 26, 4, 107, 0, 0));
    versionsM.push_back(Version(13, 'M', 2672, 334, 796,  483, 331, 204, 22, 8, 37, 1, 38));
    versionsQ.push_back(Version(13, 'Q', 1952, 244, 580,  352, 241, 149, 24, 8, 20, 4, 21));
    versionsH.push_back(Version(13, 'H', 1440, 180, 427,  259, 177, 109, 22, 12, 11, 4, 12));

    versionsL.push_back(Version(14, 'L', 3688, 461, 1101, 667, 458, 282, 30, 3, 115, 1, 116));
    versionsM.push_back(Version(14, 'M', 2920, 365, 871,  528, 362, 223, 24, 4, 40, 5, 41));
    versionsQ.push_back(Version(14, 'Q', 2088, 261, 621,  376, 258, 159, 20, 11, 16, 5, 17));
    versionsH.push_back(Version(14, 'H', 1576, 197, 468,  283, 194, 120, 24, 11, 12, 5, 13));

    versionsL.push_back(Version(15, 'L', 4184, 523, 1250, 758, 520, 320, 22, 5, 87, 1, 88));
    versionsM.push_back(Version(15, 'M', 3320, 415, 991,  600, 412, 254, 24, 5, 41, 5, 42));
    versionsQ.push_back(Version(15, 'Q', 2360, 295, 703,  426, 292, 180, 30, 5, 24, 7, 25));
    versionsH.push_back(Version(15, 'H', 1784, 223, 530,  321, 220, 136, 24, 11, 12, 7, 13));

    versionsL.push_back(Version(16, 'L', 4712, 589, 1408, 854, 586, 361, 24, 5, 98, 1, 99));
    versionsM.push_back(Version(16, 'M', 3624, 453, 1082, 656, 450, 277, 28, 7, 45, 3, 46));
    versionsQ.push_back(Version(16, 'Q', 2600, 325, 775,  470, 322, 198, 24, 15, 19, 2, 20));
    versionsH.push_back(Version(16, 'H', 2024, 253, 602,  365, 250, 154, 30, 3, 15, 13, 16));

    versionsL.push_back(Version(17, 'L', 5176, 647, 1548, 938, 644, 397, 28, 1, 107, 5, 108));
    versionsM.push_back(Version(17, 'M', 4056, 507, 1212, 734, 504, 310, 28, 10, 46, 1, 47));
    versionsQ.push_back(Version(17, 'Q', 2936, 367, 876,  531, 364, 224, 28, 1, 22, 15, 23));
    versionsH.push_back(Version(17, 'H', 2264, 283, 674,  408, 280, 173, 28, 2, 14, 17, 15));

    versionsL.push_back(Version(18, 'L', 5768, 721, 1725, 1046, 718, 442, 30, 5, 120, 1, 121));
    versionsM.push_back(Version(18, 'M', 4504, 563, 1346, 816,  560, 345, 26, 9, 43, 4, 44));
    versionsQ.push_back(Version(18, 'Q', 3176, 397, 948,  574,  394, 243, 28, 17, 22, 1, 23));
    versionsH.push_back(Version(18, 'H', 2504, 313, 746,  425,  310, 191, 28, 2, 14, 19, 15));

    versionsL.push_back(Version(19, 'L', 6360, 795, 1903, 1153, 792, 488, 28, 3, 113, 4, 114));
    versionsM.push_back(Version(19, 'M', 5016, 627, 1500, 909,  624, 384, 26, 3, 44, 11, 45));
    versionsQ.push_back(Version(19, 'Q', 3560, 445, 1063, 644,  442, 272, 26, 17, 21, 4, 22));
    versionsH.push_back(Version(19, 'H', 2728, 341, 813,  493,  338, 208, 26, 9, 13, 16, 14));

    versionsL.push_back(Version(20, 'L', 6888, 861, 2061, 1249, 858, 528, 28, 3, 107, 5, 108));
    versionsM.push_back(Version(20, 'M', 5352, 669, 1600, 970,  666, 410, 26, 3, 41, 13, 42));
    versionsQ.push_back(Version(20, 'Q', 3880, 485, 1159, 702,  482, 297, 30, 15, 24, 5, 25));
    versionsH.push_back(Version(20, 'H', 3080, 385, 919,  557,  382, 235, 28, 15, 15, 10, 16));

    versionsL.push_back(Version(21, 'L', 7456, 932, 2232, 1352, 929, 572, 28, 4, 116, 4, 117));
    versionsM.push_back(Version(21, 'M', 5712, 714, 1708, 1035, 711, 428, 26, 17, 42, 0, 0));
    versionsQ.push_back(Version(21, 'Q', 4096, 512, 1224, 742,  509, 314, 28, 17, 22, 6, 23));
    versionsH.push_back(Version(21, 'H', 3248, 406, 969,  587,  403, 248, 30, 19, 16, 6, 17));

    versionsL.push_back(Version(22, 'L', 8048, 1006, 2409, 1460, 1003, 618, 28, 2, 111, 7, 112));
    versionsM.push_back(Version(22, 'M', 6256, 782,  1872, 1134, 779,  480, 28, 17, 46, 0, 0));
    versionsQ.push_back(Version(22, 'Q', 4544, 568,  1358, 823,  565,  348, 30, 7, 24, 16, 25));
    versionsH.push_back(Version(22, 'H', 3536, 442,  1056, 640,  439,  270, 24, 34, 13, 0, 0));

    versionsL.push_back(Version(23, 'L', 8752, 1094, 2620, 1588, 1091, 672, 30, 4, 121, 5, 122));
    versionsM.push_back(Version(23, 'M', 6880, 860,  2059, 1248, 857,  528, 28, 4, 47, 14, 48));
    versionsQ.push_back(Version(23, 'Q', 4912, 614,  1468, 890,  611,  376, 30, 11, 24, 14, 25));
    versionsH.push_back(Version(23, 'H', 3712, 464,  1108, 672,  461,  284, 30, 16, 15, 14, 16));

    versionsL.push_back(Version(24, 'L', 9392, 1174, 2812, 1704, 1171, 721, 30, 6, 117, 4, 118));
    versionsM.push_back(Version(24, 'M', 7312, 914,  2188, 1326, 911,  561, 28, 6, 45, 14, 46));
    versionsQ.push_back(Version(24, 'Q', 5312, 664,  1588, 963,  661,  407, 30, 11, 24, 16, 25));
    versionsH.push_back(Version(24, 'H', 4112, 514,  1228, 744,  511,  315, 30, 30, 16, 2, 17));

    versionsL.push_back(Version(25, 'L', 10208, 1276, 3057, 1853, 1273, 784, 26, 8, 106, 4, 107));
    versionsM.push_back(Version(25, 'M', 8000,  1000, 2395, 1451, 997,  614, 28, 8, 47, 13, 48));
    versionsQ.push_back(Version(25, 'Q', 5744,  718,  1718, 1041, 715,  440, 30, 7, 24, 22, 25));
    versionsH.push_back(Version(25, 'H', 4304,  538,  1286, 779,  535,  330, 30, 22, 15, 13, 16));

    versionsL.push_back(Version(26, 'L', 10960, 1370, 3283, 1990, 1367, 842, 28, 10, 114, 2, 115));
    versionsM.push_back(Version(26, 'M', 8496,  1062, 2544, 1542, 1059, 652, 28, 19, 46, 4, 47));
    versionsQ.push_back(Version(26, 'Q', 6032,  754,  1804, 1094, 751,  462, 28, 28, 22, 6, 23));
    versionsH.push_back(Version(26, 'H', 4768,  596,  1425, 864,  593,  365, 30, 33, 16, 4, 17));

    versionsL.push_back(Version(27, 'L', 11744, 1468, 3517, 2132, 1465, 902, 30, 8, 122, 4, 123));
    versionsM.push_back(Version(27, 'M', 9024,  1128, 2701, 1637, 1125, 692, 28, 22, 45, 3, 46));
    versionsQ.push_back(Version(27, 'Q', 6464,  808,  1993, 1172, 805,  496, 30, 8, 23, 26, 24));
    versionsH.push_back(Version(27, 'H', 5024,  628,  1501, 910,  625,  385, 30, 12, 15, 28, 16));

    versionsL.push_back(Version(28, 'L', 12248, 1531, 3669, 2223, 1528, 940, 30, 3, 117, 10, 118));
    versionsM.push_back(Version(28, 'M', 9544,  1193, 2857, 1732, 1190, 732, 28, 3, 45, 23, 46));
    versionsQ.push_back(Version(28, 'Q', 6968,  871,  2085, 1263, 868,  534, 30, 4, 24, 31, 25));
    versionsH.push_back(Version(28, 'H', 5288,  661,  1581, 958,  658,  405, 30, 11, 15, 31, 16));

    versionsL.push_back(Version(29, 'L', 13048, 1631, 3909, 2369, 1628, 1002, 30, 7, 116, 7, 117));
    versionsM.push_back(Version(29, 'M', 10136, 1267, 3035, 1839, 1264, 778, 28, 21, 45, 7, 46));
    versionsQ.push_back(Version(29, 'Q', 7288,  911,  2181, 1322, 908,  559, 30, 1, 23, 37, 24));
    versionsH.push_back(Version(29, 'H', 5608,  701,  1677, 1016, 698,  430, 30, 19, 15, 26, 16));

    versionsL.push_back(Version(30, 'L', 13880, 1735, 4158, 2520, 1732, 1066, 30, 5, 115, 10, 116));
    versionsM.push_back(Version(30, 'M', 10984, 1373, 3289, 1994, 1370, 843, 28, 19, 47, 10, 48));
    versionsQ.push_back(Version(30, 'Q', 7880,  985,  2358, 1429, 982,  604, 30, 15, 24, 25, 25));
    versionsH.push_back(Version(30, 'H', 5960,  745,  1782, 1080, 742,  457, 30, 23, 15, 25, 16));

    versionsL.push_back(Version(31, 'L', 14744, 1843, 4417, 2677, 1840, 1132, 30, 13, 115, 3, 116));
    versionsM.push_back(Version(31, 'M', 11640, 1455, 3486, 2113, 1452, 894, 28, 2, 46, 29, 47));
    versionsQ.push_back(Version(31, 'Q', 8264,  1033, 2473, 1499, 1030, 634, 30, 42, 24, 1, 25));
    versionsH.push_back(Version(31, 'H', 6344,  793,  1897, 1150, 790,  486, 30, 23, 15, 28, 16));

    versionsL.push_back(Version(32, 'L', 15640, 1955, 4686, 2840, 1952, 1201, 30, 17, 115, 0, 0));
    versionsM.push_back(Version(32, 'M', 12328, 1541, 3693, 2238, 1538, 947, 28, 10, 46, 23, 47));
    versionsQ.push_back(Version(32, 'Q', 8920,  1115, 2670, 1618, 1112, 684, 30, 10, 24, 35, 25));
    versionsH.push_back(Version(32, 'H', 6760,  845,  2022, 1226, 842,  518, 30, 19, 15, 35, 16));

    versionsL.push_back(Version(33, 'L', 16568, 2071, 4965, 3009, 2068, 1273, 30, 17, 115, 1, 116));
    versionsM.push_back(Version(33, 'M', 13048, 1631, 3909, 2369, 1628, 1002, 28, 14, 46, 21, 47));
    versionsQ.push_back(Version(33, 'Q', 9368,  1171, 2805, 1700, 1168, 719, 30, 29, 24, 19, 25));
    versionsH.push_back(Version(33, 'H', 7208,  901,  2157, 1307, 898,  553, 30, 11, 15, 46, 16));

    versionsL.push_back(Version(34, 'L', 17528, 2191, 5253, 3183, 2188, 1347, 30, 13, 115, 6, 116));
    versionsM.push_back(Version(34, 'M', 13800, 1725, 4134, 2506, 1722, 1060, 28, 14, 46, 23, 47));
    versionsQ.push_back(Version(34, 'Q', 9848,  1231, 2949, 1787, 1228, 756, 30, 44, 24, 7, 25));
    versionsH.push_back(Version(34, 'H', 7688,  961,  2301, 1394, 958,  590, 30, 59, 16, 1, 17));

    versionsL.push_back(Version(35, 'L', 18448, 2306, 5529, 3351, 2303, 1417, 30, 12, 121, 7, 122));
    versionsM.push_back(Version(35, 'M', 14496, 1812, 4343, 2632, 1809, 1113, 28, 12, 47, 26, 48));
    versionsQ.push_back(Version(35, 'Q', 10288, 1286, 3081, 1867, 1283, 790, 30, 39, 24, 14, 25));
    versionsH.push_back(Version(35, 'H', 7888,  986,  2361, 1431, 983,  605, 30, 22, 15, 41, 16));

    versionsL.push_back(Version(36, 'L', 19472, 2434, 5836, 3537, 2431, 1496, 30, 6, 121, 14, 122));
    versionsM.push_back(Version(36, 'M', 15312, 1914, 4588, 2780, 1911, 1176, 28, 6, 47, 34, 48));
    versionsQ.push_back(Version(36, 'Q', 10832, 1354, 3244, 1966, 1351, 832, 30, 46, 24, 10, 25));
    versionsH.push_back(Version(36, 'H', 8432,  1054, 2524, 1530, 1051, 647, 30, 2, 15, 64, 16));

    versionsL.push_back(Version(37, 'L', 20528, 2566, 6153, 3729, 2563, 1577, 30, 17, 122, 4, 123));
    versionsM.push_back(Version(37, 'M', 15936, 1992, 4775, 2894, 1989, 1224, 28, 29, 46, 14, 47));
    versionsQ.push_back(Version(37, 'Q', 11408, 1426, 3417, 2071, 1423, 876, 30, 49, 24, 10, 25));
    versionsH.push_back(Version(37, 'H', 8768,  1096, 2625, 1591, 1093, 673, 30, 24, 15, 46, 16));

    versionsL.push_back(Version(38, 'L', 21616, 2702, 6479, 3927, 2699, 1661, 30, 4, 122, 18, 123));
    versionsM.push_back(Version(38, 'M', 16816, 2102, 5039, 3054, 2099, 1292, 28, 13, 46, 32, 47));
    versionsQ.push_back(Version(38, 'Q', 12016, 1502, 3599, 2181, 1499, 923, 30, 48, 24, 14, 25));
    versionsH.push_back(Version(38, 'H', 9136,  1142, 2735, 1658, 1139, 701, 30, 42, 15, 32, 16));

    versionsL.push_back(Version(39, 'L', 22496, 2812, 6743, 4087, 2809, 1729, 30, 20, 117, 4, 118));
    versionsM.push_back(Version(39, 'M', 17728, 2216, 5313, 3220, 2213, 1362, 28, 40, 47, 7, 48));
    versionsQ.push_back(Version(39, 'Q', 12656, 1582, 3791, 2298, 1579, 972, 30, 43, 24, 22, 25));
    versionsH.push_back(Version(39, 'H', 9776,  1222, 2927, 1774, 1219, 750, 30, 10, 15, 67, 16));

    versionsL.push_back(Version(40, 'L', 23648, 2956, 7089, 4296, 2953, 1817, 30, 19, 118, 6, 119));
    versionsM.push_back(Version(40, 'M', 18672, 2334, 5596, 3391, 2331, 1435, 28, 18, 47, 31, 48));
    versionsQ.push_back(Version(40, 'Q', 13328, 1666, 3993, 2420, 1663, 1024, 30, 34, 24, 34, 25));
    versionsH.push_back(Version(40, 'H', 10208, 1276, 3057, 1852, 1273, 784, 30, 20, 15, 61, 16));
    
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(7);
    numRemainderBits.push_back(7);
    numRemainderBits.push_back(7);
    numRemainderBits.push_back(7);
    numRemainderBits.push_back(7);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(4);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(3);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);
    numRemainderBits.push_back(0);

    characterCountIndicator_1_9.push_back(10);
    characterCountIndicator_1_9.push_back(9);
    characterCountIndicator_1_9.push_back(8);
    characterCountIndicator_1_9.push_back(8);
    
    characterCountIndicator_10_26.push_back(12);
    characterCountIndicator_10_26.push_back(11);
    characterCountIndicator_10_26.push_back(16);
    characterCountIndicator_10_26.push_back(10);
    
    characterCountIndicator_27_40.push_back(14);
    characterCountIndicator_27_40.push_back(13);
    characterCountIndicator_27_40.push_back(16);
    characterCountIndicator_27_40.push_back(12);

}

std::vector<Version> Versions::GetVersions(char level)
{
    switch (level) {
    case ERROR_CORRECTION_LEVEL_L:
        return versionsL;
        break;
    case ERROR_CORRECTION_LEVEL_M:
        return versionsM;
        break;
    case ERROR_CORRECTION_LEVEL_Q:
        return versionsQ;
        break;
    case ERROR_CORRECTION_LEVEL_H:
        return versionsH;
        break;
    default:
        break;
    }
}

bool Versions::IsWithinCapacity(int length, std::string &model, char &level)
{
    if(length <= GetMaxCapacity(model, level)) {
        return true;
    } else {
        return false;
    }

}

int Versions::GetCapacity(int version1, std::string &model1, char &level1)
{
    std::vector<Version> vec = GetVersions(level1);
    Version _ver = vec.at(version1);
    if(model1 == MODEL_INDICATOR_NUM) {
        return _ver.GetNumeric();
    } else if(model1 == MODEL_INDICATOR_AN) {
        return _ver.GetAlphaNumeric();
    } else if(model1 == MODEL_INDICATOR_BYTE) {
        return _ver.GetByte();
    } else if(model1 == MODEL_INDICATOR_ECI) {
        return _ver.getEci();
    } else if(model1 == MODEL_INDICATOR_HZ){
        return _ver.GetHanzi();
    } else {
        return 0;
    }
}

int Versions::GetMaxDataBits(int version, char level)
{
    std::vector<Version> vec = GetVersions(level);
    Version _ver = vec.at(version-1);
    return _ver.GetNumDataBits();
}

std::vector<int> Versions::GetBreakInfo(int version, char level)
{
    std::vector<Version> vec = GetVersions(level);
    Version _ver = vec.at(version-1);
    std::vector<int> breakInfo = _ver.GetBreakInfo();
    return breakInfo;
}

std::vector<char> Versions::GetRemainderBits(int version)
{
    int m = numRemainderBits.at(version -1);
    std::vector<char> vec;
    for(int i = 0; i < m; i++){
        vec.push_back('0');
    }
    return vec;
}

int Versions::GetGetRemainderBitsLength(int version)
{
    int m = numRemainderBits.at(version -1);
    return m;
}

std::string Versions::GetCharacterCountIndicator(std::string &model, int version, int length)
{
    //std::vector<int> _vec;
    //int count;
    std::string strCountIndi;
    if(version < 10){
        //_vec = characterCountIndicator_1_9;
        if (model == MODEL_INDICATOR_NUM) {
            std::bitset<10> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_AN) {
            std::bitset<9> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_BYTE) {
            std::bitset<8> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_ECI) {
            std::bitset<8> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_HZ) {
            std::bitset<8> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else {
        }
    } else if(version < 27) {
        //_vec = characterCountIndicator_10_26;
        if (model == MODEL_INDICATOR_NUM) {
            std::bitset<12> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_AN) {
            std::bitset<11> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_BYTE) {
            std::bitset<16> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_ECI) {
            std::bitset<16> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_HZ) {
            std::bitset<10> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else {
        }
    } else {
        //_vec = characterCountIndicator_27_40;
        if (model == MODEL_INDICATOR_NUM) {
            std::bitset<14> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_AN) {
            std::bitset<13> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_BYTE) {
            std::bitset<16> countIndi = length;
            strCountIndi = countIndi.to_string();
        }  else if(model == MODEL_INDICATOR_ECI) {
            std::bitset<16> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else if(model == MODEL_INDICATOR_HZ) {
            std::bitset<12> countIndi = length;
            strCountIndi = countIndi.to_string();
        } else {
        }
    }

    return strCountIndi;
}

int Versions::GetCharacterCount(std::__cxx11::string &model, int version)
{
    if(version < 10){
        //_vec = characterCountIndicator_1_9;
        if (model == MODEL_INDICATOR_NUM) {
            return 10;
        } else if(model == MODEL_INDICATOR_AN) {
            return 9;
        } else if(model == MODEL_INDICATOR_BYTE) {
            return 8;
        } else if(model == MODEL_INDICATOR_ECI) {
            return 8;
        } else if(model == MODEL_INDICATOR_HZ) {
            return 8;
        } else {
        }
    } else if(version < 27) {
        //_vec = characterCountIndicator_10_26;
        if (model == MODEL_INDICATOR_NUM) {
            return 12;
        } else if(model == MODEL_INDICATOR_AN) {
            return 11;
        } else if(model == MODEL_INDICATOR_BYTE) {
            return 16;
        } else if(model == MODEL_INDICATOR_ECI) {
            return 16;
        } else if(model == MODEL_INDICATOR_HZ) {
            return 10;
        } else {
        }
    } else {
        //_vec = characterCountIndicator_27_40;
        if (model == MODEL_INDICATOR_NUM) {
            return 14;
        } else if(model == MODEL_INDICATOR_AN) {
            return 13;
        } else if(model == MODEL_INDICATOR_BYTE) {
            return 16;
        }  else if(model == MODEL_INDICATOR_ECI) {
            return 16;
        } else if(model == MODEL_INDICATOR_HZ) {
            return 12;
        } else {
        }
    }
}

int Versions::GetMaxCapacity(std::string &model, char &level)
{
    return GetCapacity(39, model, level);
}

}
